<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no" />
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>我的库存</title>
    <link rel="stylesheet" href="../../css/base.css">
    <link rel="stylesheet" href="../../css/mywholesale/index.css">
    <script src="../../js/jquery-2.2.3.min.js"></script>
    <script src="../../js/rem.js"></script>
    <script src="../../js/common.js"></script>
    <style>
    .head{
        position: relative;
    }
    .item-price{
        float:left;
        margin-right: 0.6rem;
    }
    .yiqianbao{
        width: 95%;
        margin: 0 auto;
        height: 0.8rem;
        background: #e56969;
        border-radius: 0.1rem;
        margin-top: 0.1rem;
    }
    .balance{
        width: 100%;
        text-align: center;
        color: #ffffff;
        font-size: 0.16rem;
        line-height: 0.8rem;
    }
    .h-right{
        position: absolute;
        font-size: 0.16rem;
        line-height: 0.4rem;
        color: #000;
        right: 0.15rem;
    }
    </style>
</head>

<body style="background-color: #F5F5F5">
    <div class="head">
        <a href="javascript:history.back(-1)">
            <div class="h-left"></div>
        </a>
        <div class="h-middle" style="margin: 0 auto; line-height:0.4rem;">我的库存</div>
        <div class="h-right" onclick="location.href='xiangxi.html'">转换明细</div>
    </div>
    <!-- <div style="height: .44rem;"></div> -->
    <div class="yiqianbao">
        <p class="balance">可用余额：</p>
    </div>
    <div class="contBox">
        <!--进行中-->
        <div class="cont-item">

        </div>
    </div>
</body>
<script>
    $(function () {
        $('.sqhg').click(function () {
            $('.zhezhao').show()
        })
        $('.true').click(function () {
            $('.zhezhao').hide()
        })
    })
    $(document).ready(function () {
        $(".navBox li").mouseover(function () {
            //通过 .index()方法获取元素下标，从0开始，赋值给某个变量
            var _index = $(this).index();
            //让内容框的第 _index 个显示出来，其他的被隐藏
            $(".contBox>div").eq(_index).show().siblings().hide();
            //改变选中时候的选项框的样式，移除其他几个选项的样式
            $(this).addClass("isactive").siblings().removeClass("isactive");
        });
    });
    $.ajax({
        url: SURL + '/jfd/inventory/inventoryList',
        type: 'post',
        data: {
            userId: localStorage.getItem('userId')
        },
        dataType: 'json',
        success: res => {

            console.log(res.account.stockMoney)
            $('.balance').text('可用余额：'+res.account.stockMoney)
            res.list.forEach(element => {

                $('.cont-item').append(
                `
                    <div class="item-box">
                        <img src="${element.img}" class="item-img1" alt="">
                        <p class="item-p">${element.goodsName}</p>
                        <p class="item-num" style="width:100%;">×${element.stocks}
                            <span class="item-price">${element.price}</span>
                        </p>
                        <div class="item-btnBox">
                            <div class="button1 qyg" data-id="${element.kucunId}" onclick="goYi(this)">转余额</div>
                        </div>
                    </div>
                `
                )

            });
        }
    })
    function goYi(e){
        var kuncunId = $(e).attr('data-id');
        $.ajax({
            url:SURL+'/jfd/inventory/stockMoney',
            type:'post',
            data:{
                userId:localStorage.getItem('userId'),
                KucunId:kuncunId
            },
            dataType:'json',
            success:res=>{
                alert(res.msg);
                window.location.reload();
            }
        })
    }
</script>

</html>
